package com.qidian.common.beans;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.qidian.client.TransConstants;
import com.qidian.common.TableMeta;
import com.qidian.common.TransType;

public class GameTypeBean implements ISyncBean
{
	Long gameTypeId = -1L ;
	int gameType = -1;
	int point = -1;
//	int point_worker = -1;
	double point_worker = 0.0f ;
	String gameDescription = null ;
	int minInterval = -1;
	int answerType = -1;
	int answerLen = -1;
	int status = 0;
	double difficulty  = 1.0f ; // 难度系数
	TransType transOn = TransType.TRANS_MICRORUI ;	// 默认转发给微锐
	
	boolean needSync = false ;
	
	public static GameTypeBean toGameType(ResultSet rs) throws SQLException 
	{
		GameTypeBean bean = new GameTypeBean() ;
		bean.setGameTypeId(rs.getLong(TableMeta.column_game_type_id)) ;
		bean.setGameType(rs.getInt(TableMeta.column_game_type));
		bean.setPoint(rs.getInt(TableMeta.column_point_per)) ;
		bean.setPoint_worker(rs.getDouble(TableMeta.column_point_worker)) ;
		bean.setAnswerType(rs.getInt(TableMeta.column_answer_type)) ;
		bean.setGameDescription(rs.getString(TableMeta.column_game_description)) ;
		bean.setMinInterval(rs.getInt(TableMeta.column_min_interval)) ;
		bean.setAnswerLen(rs.getInt(TableMeta.column_answer_length));
		bean.setSupport(rs.getInt(TableMeta.column_status));
		bean.setTransOn(rs.getInt(TableMeta.column_trans_on)) ;
		bean.setDifficulty(rs.getDouble(TableMeta.column_difficulty));
		return bean;
	}
	
	public boolean isTransOn()
	{
		return transOn.getTransCode() > 0 ;
	}
	
	
	public String getGameDescription() {
		return gameDescription;
	}
	public String getAnswerTypeDes()
	{
		return AnswerType.values()[answerType].getDescription() ;
	}
	public void setGameDescription(String gameDescription) {
		this.gameDescription = gameDescription;
	}
	public int getMinInterval() {
		return minInterval;
	}
	public void setMinInterval(int minInterval) {
		this.minInterval = minInterval;
	}
	public int getAnswerType() {
		return answerType;
	}
	public void setAnswerType(int answerType) {
		this.answerType = answerType;
	}

	public int getGameType() {
		return gameType;
	}
	public void setGameType(int gameType) {
		this.gameType = gameType;
	}
	public int getPoint() {
		return point;
	}
	public void setPoint(int point) {
		this.point = point;
	}
	public double getPoint_worker() {
		return point_worker;
	}
	public void setPoint_worker(double point_worker) {
		this.point_worker = point_worker;
	}

	public int getAnswerLen() {
		return answerLen;
	}

	public void setAnswerLen(int answerLen) {
		this.answerLen = answerLen;
	}

	public int getSupport() {
		return status;
	}

	public void setSupport(int support) {
		this.status = support;
	}
	
	

	/**
	 * 是否自定义超时时间
	 * 
	 * */
	public boolean isUdInterval() 
	{
		return this.minInterval <= 0;
	}

	public Long getGameTypeId() {
		return gameTypeId;
	}

	public void setGameTypeId(Long gameTypeId) {
		this.gameTypeId = gameTypeId;
	}

	@Override
	public PreparedStatement getPreparedStatement(Connection conn)
			throws SQLException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean isDeleted() 
	{
		return status == -1;
	}

	@Override
	public boolean needSynchronized() {
		// TODO Auto-generated method stub
		return needSync;
	}

	@Override
	public void setDeleted() {
		status = -1 ;
	}

	@Override
	public boolean setParameters(PreparedStatement ps) {
		// TODO Auto-generated method stub
		return false;
	}

	public TransType getTransOn() {
		return transOn;
	}

	public void setTransOn(int transOn) {
		this.transOn = TransType.getTransType(transOn);
	}

	public double getDifficulty() {
		return difficulty;
	}

	public void setDifficulty(double difficulty) {
		this.difficulty = difficulty;
	}
}
